package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.CompanyDao;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CompanyImpl implements CompanyDao {
    @Override
    public CompanyModel getCompanyModel() {
        String sql="select * from company where is_show=1";
        CompanyModel model=new CompanyModel();
        ResultSet resultSet= JDBC.query(sql);
        try {
            while (resultSet.next()){
                model.setId(resultSet.getInt("id"));
                model.setLogo(resultSet.getString("logo"));
                model.setPhone(resultSet.getString("phone"));
                model.setNet(resultSet.getString("net"));
                model.setEmail(resultSet.getString("email"));
                model.setLinePhone(resultSet.getString("line_phone"));
                model.setAddress(resultSet.getString("address"));
                model.setVersion(resultSet.getString("version"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return model;
    }

    @Override
    public int add(CompanyModel companyModel) {
        return 0;
    }
}
